package Func;

import Book.Book;
import Book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 38917
 * Date: 2025-02-16
 * Time: 02:19
 */
public class FindFunc implements Func{
    @Override
    public void work(BookList bookList) {
        Scanner in = new Scanner(System.in);
        System.out.println("请输入你要查找的书名");
        String name = in.nextLine();
        int curSize = bookList.getUsedSize();
        for (int i = 0; i < curSize; i++) {
            Book book = bookList.getBooks(i);
            if (book.getName().equals(name)){
                System.out.println("找到了你要查找的图书");
                System.out.println(book);
                return;//结束方法
            }
        }
        System.out.println("没有你要查找的图书");
    }
}
